package com.relatev.minecraft.TRAttribute;

import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;

public class TRAEntityUtils {

    public static void sendMessage(LivingEntity lent, String message) {
        if (lent instanceof Player) {
            ((Player) lent).sendMessage(message);
        }
    }

    public static void healLivingEntity(LivingEntity lent, double hp) {
        if (TRASupportUtils.getLivingEntityMaxHealthy(lent) < lent.getHealth() + hp) {
            lent.setHealth(TRASupportUtils.getLivingEntityMaxHealthy(lent));
        } else {
            lent.setHealth(lent.getHealth() + hp);
        }
    }

    public static void decreaseHealth(LivingEntity lent, double hp) {
        if (lent.getHealth() > hp) {
            lent.setHealth(lent.getHealth() - hp);
        }else{
            lent.setHealth(0);
        }
    }
}
